package com.invest.utils.rest;

import com.google.gson.Gson;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;

/**
 * Created by evan on 2016/6/11.
 */
public class RestClientUtils {

    public static HttpEntity<String> buildJsonBody(Object param){

        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());

        String json = new Gson().toJson(param);
        HttpEntity<String> formEntity = new HttpEntity<String>(json, headers);
        return formEntity;
    }
}
